/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fallen.deck.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Carlos S. Moreno <CarlosS.Moreno@gmail.com>
 */
public class Card implements Comparable, Serializable{

    private Expansion expansion;
    private int number;
    private Pathway pathway; //Senda
    private String name, effect, text, cost, str, res;
    private List type, subtype, supertype, artist;
    private Frequency frequency;
    private long id;

    public String getFullDescription()
    {
        String desc = "Expansion: " + expansion.getName() + "\tNúmero: " + number;
        if (supertype != null && supertype.size() > 0)
        {
            desc += "\nSuper-tipo: ";
            Iterator iterator = supertype.iterator();
            while (iterator.hasNext())
            {
                desc += ((Supertype)iterator.next()).getName() + " ";
            }
        }
        if (type != null && type.size() > 0)
        {
            desc += "\nTipo: ";
            Iterator iterator = type.iterator();
            while (iterator.hasNext())
            {
                desc += ((Type)iterator.next()).getName() + " ";
            }
        }
        if (subtype != null && subtype.size() > 0)
        {
            desc += "\nSub-tipo: ";
            Iterator iterator = subtype.iterator();
            while (iterator.hasNext())
            {
                desc += ((Subtype)iterator.next()).getName() + " ";
            }
        }
        if (cost != null) desc += "\nCoste: " + cost;
        if (effect != null && effect.compareToIgnoreCase("") != 0 )        
            desc += "\nEfecto: " + effect;
        if (text != null && text.compareToIgnoreCase("") != 0)        
            desc += "\nTexto Ambientación: " + text;
        if (str != null) desc += "\nFUE: " + str;
        if (res != null) desc += "\nRES: " + res;
        
        return desc;
    }
    
    public Card()
    {
        initVars();
    }

    private void initVars() {
        type = new ArrayList();
        subtype = new ArrayList();
        supertype = new ArrayList();
        artist = new ArrayList();
        //name = effect = text = cost = str = res = "";
    }
    
    public Card(String name)
    {
        initVars();
        this.name = name;        
    }

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }
    
    
    @Override
    public int compareTo(Object o) {
        if (!(o instanceof Card)) return -1;
        int exp=((Card)o).getExpansion().compareTo(getExpansion());
        int num=((Card)o).getNumber()-getNumber();
        return exp + num;
    }

    /**
     * @return the expansion
     */
    public Expansion getExpansion() {
        return expansion;
    }

    /**
     * @param expansion the expansion to set
     */
    public void setExpansion(Expansion expansion) {
        this.expansion = expansion;
    }

    /**
     * @return the number
     */
    public int getNumber() {
        return number;
    }

    /**
     * @param number the number to set
     */
    public void setNumber(int number) {
        this.number = number;
    }

    /**
     * @return the str
     */
    public String getStr() {
        return str;
    }

    /**
     * @param str the str to set
     */
    public void setStr(String str) {
        this.str = str;
    }

    /**
     * @return the res
     */
    public String getRes() {
        return res;
    }

    /**
     * @param res the res to set
     */
    public void setRes(String res) {
        this.res = res;
    }

    /**
     * @return the pathway
     */
    public Pathway getPathway() {
        return pathway;
    }

    /**
     * @param pathway the pathway to set
     */
    public void setPathway(Pathway pathway) {
        this.pathway = pathway;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the effect
     */
    public String getEffect() {
        return effect;
    }

    /**
     * @param effect the effect to set
     */
    public void setEffect(String effect) {
        this.effect = effect;
    }

    /**
     * @return the text
     */
    public String getText() {
        return text;
    }

    /**
     * @param text the text to set
     */
    public void setText(String text) {
        this.text = text;
    }

    /**
     * @return the type
     */
    public List getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(List type) {
        this.type = type;
    }

    /**
     * @return the subtype
     */
    public List getSubtype() {
        return subtype;
    }

    /**
     * @param subtype the subtype to set
     */
    public void setSubtype(List subtype) {
        this.subtype = subtype;
    }

    /**
     * @return the race
     */
    public List getSupertype() {
        return supertype;
    }

    /**
     * @param race the race to set
     */
    public void setSupertype(List race) {
        this.supertype = race;
    }

    /**
     * @return the artist
     */
    public List getArtist() {
        return artist;
    }

    /**
     * @param artist the artist to set
     */
    public void setArtist(List artist) {
        this.artist = artist;
    }

    /**
     * @return the frequency
     */
    public Frequency getFrequency() {
        return frequency;
    }

    /**
     * @param frequency the frequency to set
     */
    public void setFrequency(Frequency frequency) {
        this.frequency = frequency;
    }

    /**
     * @return the cost
     */
    public String getCost() {
        return cost;
    }

    /**
     * @param cost the cost to set
     */
    public void setCost(String cost) {
        this.cost = cost;
    }

    public String toString()
    {
        return name;
    }    
}
